#ifndef __AUDIO_IN_MGR_H__
#define __AUDIO_IN_MGR_H__

#include <map>
#include <mutex>
#include <functional>
#include "Pal/AudioIn.h"
#include "json.h"

#include "Thread/Thread.h"


namespace Media{

class AudioInMgr{
public:
	static AudioInMgr *instance(int channel);

	bool createAudioIn(AudioInDesc inDesc);

	bool setFormat(AudioInAttr format);

	bool start();

	bool stop();

	bool putPacket(AudioInPacket *packet);
	
private:
	AudioInMgr(int channel);
	
private:
	static std::map<int, AudioInMgr *> 	    sm_objectMap;

	static std::recursive_mutex 			sm_mapMutex;

	AudioInAttr							    m_format;
	
	AudioInput*							    m_audioInObj = nullptr;
	
	int 									m_channel = 0;
	
	bool									m_started = false; //start作为启动标志,避免多个业务多次启停

};

}//namespace Media
#endif

